define(function(require,exports,module){
	var Subnav = require("subnav");
	var aw = require("ajaxwrapper");
	var service = require("../store/roomTypeSvc");
	var user = require("store").get("user");
	var constant = require("../constant/roomTypeProps");
	
	module.exports = {
		initComponent: function(widget){
			var subnav = new Subnav({
				parentNode: ".J-subnav",
				model:{
					title: "房型信息",
					items: [{
						id: "search",
						type: "search",
						placeholder: "名称",
						handler: function(str){
						    service.search({
								s: str,
								properties: "name",
								"servicePoint.pkServicePoint": widget.get("subnav").getValue("svcPoint"),
								fetchProperties: constant.gridFetchProperties
							},function(data){
								widget.get("grid").setData(data);
								widget.get("subnav").setValue("search", "");
							});
						}
					},{
						id: "svcPoint",
						type: "buttongroup",
						items:user.privateServicePoints,
						tip: "服务点",
						keyField: "pkServicePoint",
						valueField: "name",
						handler: function(key){
							widget.get("grid").refresh();
							//切换楼宇
							widget.get("form").load("orgBuildings")
						}
					},{
						id:"add",
						type:"button",
						text: "新增",
						handler: function(){
							widget.get("form").reset();
							$(".input-group :button").addClass('btn btn-theme');
							widget.toCard();
						}
					},{
						id:"return",
						type:"button",
						text: "返回",
						show: false,
						handler: function(){
							widget.toList();
						}
					}]
				}
			});
			widget.set("subnav",subnav);
		}
	};
});